define(function(require, exports, module) {
	'use strict';
	require("resource/js/mobile/awesome/css/font-awesome.css");
	require("resource/js/mobile/css/listview.css");
	require("resource/js/mobile/css/listpanel.css");
	require("resource/js/mobile/jquery.listview.js");
	require("resource/js/mobile/jquery.listpanel.js");
	require("resource/js/component/vitoBooks/vitobooks.mobile.js");
	require("resource/css/oaTreeStyle.css");
	require("resource/js/mobile/awesome/css/font-awesome.css");
	require("resource/js/mobile/css/textbox.css");
	require("resource/js/mobile/css/combobox.css");
	require("resource/js/mobile/jquery.textbox.js");
	require("resource/js/mobile/jquery.combobox.js");
	var actcont = require("oa/act/js/actcont.js");
	var submit = require("oa/act/mobile/js/submitMobile.js");
	var painNodeForm = require("oa/act/mobile/js/paintNodeFormMoblie.js");
	var ajax = require("resource/js/component/ajax.js");
	var approverList=null;//实际审批人列表
	var approversMaxCount=0;//审批人数量
	var ccUserList = [];
	var processColor={"审批中":"#ff851a","同意":"#61b361","转交":"#5f97f6","拒绝":"#ff0000","驳回":"#ff0000","":"#b4b5b8"};
	var colors = ['#229af9', '#e91e63', '#ffc107', '#8bc34a', '#3f51b5', '#00bcd4'];
	var getDATE = function(jq) { //初始化日期控件
		function stopBubble(e) {
			if (e && e.stopPropagation)
				e.stopPropagation()
			else
				window.event.cancelBubble = true
		}
		stopBubble(this)
		jq.init();
		var result = null;
		var btns = $('.btnDateCla');
		btns.each(function(i) {
			btns[i].removeEventListener('tap', getDATE, false);
			btns[i].addEventListener('tap', function() {
				var res = this;
				var optionsJson = this.getAttribute('data-options') || '{}';
				var options = eval('(' + optionsJson + ')');
				var id = this.getAttribute('class');
				result = jq("#" + id);
				/*
				 * 首次显示时实例化组件
				 * 示例为了简洁，将 options 放在了按钮的 dom 上
				 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker
				 */
				var picker = new jq.DtPicker(options);
				if (!$(".mui-dtpicker").hasClass("mui-active")) {
					picker.show(function(rs) {
						res.value = rs.text;
						if (rs.type != "date") {
							res.value += ":00";
						}
						setOverTime(res.id, res.value);
						picker.dispose();
					});
				}
			}, false);
		});
	}
	var initCopyOfBtn = function() {
		require.async('resource/js/component/ajax.js', function(ajax) {
				$("#addCopyOf").listpanel({
					url: BASEPATH + "/base/authoriza/user/getUserListByDeptId.htm",
					dataFilter: function(data) {
						data = data.data;
						for (var i in data) {
							if (data[i].type != 'USER') {
								data[i].noCheck = true;
								data[i].icon = "icon-group";
							}
						}
						return data;
					},
					view: {
						idKey: "id",
						nameKey: "name",
						pidKey: "pid"
					},
					check: {
						type: "checkbox",
						checkbox: {
							type: {
								"Y": "p",
								"N": "s"
							}
						}
					},
					onSave: function(nodes) {
						var html = "";
						var checkUsers = [];
						$.each(nodes,function(i,val){
						   if(val.type=='USER'){
							   checkUsers.push(val);
						   }
						});			
						$.each(checkUsers, function(i, val) {
							if ($.inArray(val.id,ccUserList)==-1) {
								var text = val.name.substring(0, 1);
								var col_index = i % colors.length;
								var node_index = ccUserList.length;
								  html = "<div class='approvers-item'>" +
												"<div data-index="+node_index+" class='approvers-item-person person-delete' style='background-color: "+colors[col_index]+"'>" +
												"<span class='name-first'>"+text+"</span>" +
												 " <div class='closeTarget'></div>"+
												"</div>" +
												"<div class='personName'>"+val.name+"</div>" +
										  "</div>";
								$("#addCopyOfUsers").parent().before(html);
							    ccUserList.push(val.id);
							}
						});
						//$("#addCopyOfUsers").parent().parent().find('.person').remove();						
						$("#copyOfUsers").val("")
						$("#copyOfUsers").val(JSON.stringify(ccUserList));
					}
				});
		});
		$("#addCopyOfUsers").unbind("click");
		$("#addCopyOfUsers").bind("click", function() {
			$("#addCopyOf").listpanel("show");
		});
	}
	$("#copyUser").on('click','.person-delete',function(){
		var index = $(this).data("index");
		ccUserList.splice(index,1);
		$("#copyOfUsers").val("")
	    $("#copyOfUsers").val(JSON.stringify(ccUserList));
		$(this).parent().remove();
	});
	exports.initPage = function() {
		if (window.js && window.js.isGoback) {
			window.js.isGoback("true");
		}
		var urlTool = require("resource/js/component/urlTool.js");
		var key = urlTool.getParam("key");
		var businessName = decodeURI(urlTool.getParam("businessName"));
		var processInstanceId = urlTool.getParam("processInstanceId");
		var taskId = urlTool.getParam("taskId");
		if (businessName && businessName != null && businessName != undefined) {
			window.document.title = urlTool.ToGB2312(businessName);
		}
		if(processInstanceId != null){
			$(".approvers").hide();
		}
		initCopyOfBtn();
		showMask();
		ajax.init().success(function(code, msg, datas) {
			if (code == 0) {
				if (datas) {
					var height = 0;
					var tabMore = false;
					//初始化参数
					if (datas.key != null && datas.key != undefined) {
						$("#processKey").val(datas.key);
					}
					if (datas.processNodeId != null && datas.processNodeId != undefined) {
						$("#processNodeId").val(datas.processNodeId);
					}
					$("#processInstanceId").val(processInstanceId);
					$("#taskId").val(taskId);
					if (datas.currentUser != null && datas.currentUser != undefined) {
						$("#currentUserId").val(datas.currentUser);
					}
					if (datas.busenessId != null && datas.busenessId != undefined) {
						$("#busenessId").val(datas.busenessId);
					}
					if (datas.view && datas.view.length > 0) {
						
						var index = 0;
						var action="";
						var dealTime="";
						
						var mainView = datas.view[0];						
						var mainHtml = '<div class="result-box padding10" id="view_main" style="margin-top:10px">'
							+'<div class="result-title"><span>' + mainView.username + '的'+ businessName + '申请</span></div>'
							+'<div class="prompt"><span>申请时间：' + mainView.dealtime + '</span></div>'
							+'<hr/>'
							+'<ul class="" id="tab_0"></ul></div>';
						$('#resultForm').append(mainHtml);
						painNodeForm.load_view(key, mainView.processnodeid, datas.busenessId, mainView.taskid, 'tab_0');
						
						$("#resultForm").append('<div class="result-box result-process padding10"><div id="view_process"><div class="line"></div></div></div>');
						var itemHtml = "";
						$.each(datas.view, function(i, view) {
							itemHtml = ""
							var tabId = "Tab_" + index;
							itemHtml += '<div class="result-process-item">'
									+'<div class="process-user-photo" >'
										+'<span>'+view.username.substring(0, 1)+'</span>'
									+'</div>' 
								+'<div class="process-deal-info">'
								+'<span>' + view.username + '</span>'
								+'<span style="color:'+processColor[view.action]+'">'+(view.action||'')+'</span>'
								+'<span class="prompt" style="float:right;">' + (view.dealtime||'') + '</span>'
								+'<ul class="process-deal-advice" id="' + tabId + '"></ul></div></div>';
							$("#view_process").append(itemHtml);
							//绘制明细信息
							if(view.taskid && index > 0 && view.action != '转交'){
								painNodeForm.load_view(key, view.processnodeid, datas.busenessId, view.taskid, tabId);
							}						
							index++;
						});
						if(processInstanceId){
							$('<a id="printBtn" class="printBtn"></a>').appendTo($('.result-title'));
						}
						setTimeout(function(){
							$('.line').height($("#view_process").height()-$("#view_process").find('.result-process-item:last-child').height());
						}, 200);
					}
					if (datas.main && datas.main.length > 0) { //加载form数据
						var tab = $("#mainTab");
						var html="";
						var index = 0;
						$.each(datas.main, function(i, main) {
							var isMore = main.tab.isMore;
							html += "<input type='hidden' id='tab-" + main.tab.tableKey + "' value='" + main.tab.operType + "' />";
							if (main.cols) {
								if (isMore == "1") { //单行表单数据
									html = initFormData(main, html, 'mainIsProcess');
								}
							}
							index++;
						});
						tab.html(html);
						getDATE(mui);
					}
					if (datas.subs && datas.subs.length > 0) { //加载form数据
						var $tab;;
						if(processInstanceId){
							$tab = $('#suggestion');
						}else{
							$tab = $("#subsTab");
						}
						var html = "";
						var index = 0;
						$tab.append( "<input type='hidden' id='tab-" + datas.subs[0].tab.tableKey + "' value='" + datas.subs[0].tab.operType + "' />");
						$.each(datas.subs, function(i, subs) {
							var isMore = subs.tab.isMore;
							var tabName = subs.tab.tableKey;
							if (subs.cols) {
								if (isMore == "1") { //单行表单数据
									tabMore = false;
									html += "<ul class='inputStyle'>";
									html = initFormData(subs, html, 'subIsProcess');
									html += "</ul>";
									$tab.append(html);
								} else { //多行表格数据
									tabMore = true;
									html += initTableData(subs, 0);
									$tab.append(html);
									$tab.parent().append("<div class='sub-addBtn'><input type='button' value='+ 新增' tabKey='" + tabName + "' id='addTableBtn_" + tabName + "' /></div>");
									document.getElementById("addTableBtn_" + tabName).cols = JSON.stringify(subs.cols);
									document.getElementById("addTableBtn_" + tabName).subs = JSON.stringify(subs);
								}
							}
							index++;
						});
						if (!processInstanceId && index == datas.subs.length) {
							getDATE(mui);
							//$('#subsForm').show();
							$tab.parent().show();
						}
					}
					if (datas.btns && datas.btns.length > 0) { //加载button数据
						var btnsHtm = '';
						var showBtnNum = 4;
						$.each(datas.btns, function(i, btn) {
							if(i>showBtnNum-1){
								return false;
							} 
							var btnId = btn.id || '';
							var btnClass = btn['class']||'';
							var btnName = btn.name || '';
							var options = btn.options || '';
							//btnsHtm += '<input id="' + btnId + '" type="button" class="button '+btnClass+'" value="' + btnName + '"  data-options="'+options+'" />';
							if(!processInstanceId){
								btnsHtm += '<input id="' + btnId + '" type="button" class="button btn-create '+btnClass+'" value="' + btnName + '"  data-options="'+options+'"/>';	
							}else{
								btnsHtm += '<a id="' + btnId + '" class="approval-button '+btnClass+'"  data-options="'+options+'">'
				   				+'<span>'+btnName+'</span>'
					   			+'</a>';
							}
						});
						$("#btns").html(btnsHtm);
						//追加更多按钮
						if(processInstanceId && datas.btns.length > showBtnNum){
							var moreBtn = '<a href="javascript:void(0)"  class="approval-button" id="moreBtns">'
				   				+'<span>更多</span>'
					   			+'</a>';
							$("#btns").append(moreBtn);
							initMoreBtns(datas.btns,showBtnNum+1);
						}
					}
					addFormEvent();
					if(datas.processNodeId == 'PROCESS_START'){ //加载审批人
						//初始化加载审批人
						approverInit(datas.key);			
						//条件审批绑定条件col事件，动态刷新审批人
						if(datas.branchCol){
							var branchCol = $("#"+datas.branchCol);
							var options = eval("("+branchCol.attr("options")+")");
							if(options){
								if (options.showType == 'select') {
									branchCol.combobox({
										onSelect:function(des){
											approverInit($("#processKey").val(),des.text);
										}
									});
								} else if (options.showType == 'number') {
									if(branchCol[0].addEventListener){
										branchCol[0].addEventListener('change',function() {
											approverInit($("#processKey").val(),this.value);
										}) 
									}else{
										branchCol[0].attachEvent('onchange',function() {
											approverInit($("#processKey").val(),this.value);
										}) 
									}
 
									
								}
							}
						}	
					}
				}
			} else {
				$(".error").text(msg).show().delay(2000).hide(0);
				if (code == 11 && window.js && window.js.logout) {
					window.js.logout();
				}
			}
			$('body').css("visibility","visible");
			hideMask();
		}).post(BASEPATH + "/oa/act/activitiMain/getMobileProcessPage.htm", {
			key: key,
			processInstanceId: processInstanceId,
			taskId: taskId
		});
	}
	//初始化按钮弹窗
	var initMoreBtns = function(btns,startIndex){
		var html='';
		if(btns&&btns.length>0){
			var btnId='';
			var btnClass='';
			var btnName ='';
			var options ='';
			for(var i=0;i<btns.length;i++){
				if(i>=startIndex){
					btnId = btns[i].id || '';
					btnClass = btns[i]['class']||'';
					btnName = btns[i].name || '';
					options = btns[i].options || '';
					html += '<li id="' + btnId + '" class="'+btnClass+'" data-options="'+options+'">'+btnName+'</li>'
				}
			}
		}
		$('#btnsDlg .dlg-body').append(html);	
		$('#btnsDlg').css('margin-left',-($('#btnsDlg').width()/2));
		$('#btnsDlg').css('margin-top',-($('#btnsDlg').height()/2));	
		$('#btnsDlg .dlg-cancel').unbind('click');
		$('#btnsDlg .dlg-cancel').bind('click',function(){
			$('#btnsDlg').hide();
			hideMask();
		});

	};
	
	//预置审批人显示
	var paintApproverHtml = function(auditor,index){
		var nodeId = auditor.nodeId;
		var orderNum = auditor.orderNum;
		var nodeName=auditor.nodeName;
		var userType = auditor.userType;
		var users = auditor.users;
		var nameText = users[0].name;
		var firstNameText = nameText.substring(0,1);
		var col_index=index%colors.length;
		var approver;
		var html = "<div class='approvers-item' id='"+nodeId+"'>" +
						"<div class='approvers-item-person' style='background-color: "+colors[col_index]+"'>" +
							"<span class='name-first'>"+firstNameText+"</span>" +
						"</div>" +
						"<div class='personName'>"+nameText+"</div>" +
						"<div class='approvers-item-type'>"+nodeName+"</div>" +
						"<div class='approvers-item-line'></div>" +
					"</div>";
		var result = {
				'userid' : function() {
					var id = "";
					if(users.length > 1){
						$("#approversDiv").append('<div style="width:auto;margin-left:7px;" class="approvers-item" id="'+nodeId+'"><div class="approvers-mutil"></div></div>');
						$.each(users,function(i,item){
							id += (item.id+',');
							var h = 
								"<div class='mutil-item'>"+
							"<div class='approvers-item-person' style='background-color: "+colors[i%colors.length]+"'>" +
								"<span class='name-first'>"+item.name.substring(0,1)+"</span>" +
							"</div>" +
							"<div class='personName'>"+item.name+"</div></div>" ;
							$("#"+nodeId).find(".approvers-mutil").append(h);
						});
						var width = $("#"+nodeId).find(".approvers-mutil").width();
						$("#"+nodeId).append("<div class='approvers-item-line'></div>");
						$("#"+nodeId).append("<div class='approvers-item-type' style='width:"+(width+2)+"px;'>"+nodeName+"</div>");
						$("#"+nodeId).find(".approvers-mutil").width(width);
						$("#"+nodeId).width(width+27)
					}else{
						id = users[0].id;
						$("#approversDiv").append(html);
					}
					approver = {"nodeId":nodeId,"orderNum":orderNum,"userType":userType,"userId":id,approveStatus:1};
					approverList[orderNum-1] = approver;
				},
				'deptid' : function() {
					$("#approversDiv").append(html);
					approver = {"nodeId":nodeId,"orderNum":orderNum,"userType":userType,"userId":users[0].id,approveStatus:1};
					approverList[orderNum-1] = approver;
				},
				'director':function(){
					$("#approversDiv").append(html);
					approver = {"nodeId":nodeId,"orderNum":orderNum,"userType":userType,"userId":users[0].id,approveStatus:1};
					approverList[orderNum-1] = approver;
				},
				'roleid' : function() {
					var roleUsers = users;
					var color = col_index;
					var roleName = auditor.roleName;
					html = "<div class='approvers-item' id='"+nodeId+"'>" +
								"<div id='addApprover' class='approvers-item-person' style='background-color: #fff;border:1px solid #229af9' title='编辑'>"
									+ "<a class='addbtn' href='javascript:void(0)'>+</a>"+
								"</div>"+
								"<div class='personName'>添加</div>"+
								"<div class='approvers-item-type'>"+nodeName+"</div>" +
								"<div class='approvers-item-line'></div>" +
							"</div>";						
					$("#approversDiv").append(html);
					if($("#"+nodeId)){
						$("#"+nodeId).find("#addApprover").unbind("click");
						$("#"+nodeId).find("#addApprover").bind('click',function(){
							$("#addApproverOfRole").data('current-node',auditor);
							$("#addApproverOfRole").listpanel({
								data:roleUsers,
								view: {
									idKey: "id",
									nameKey: "name",
									pidKey: "pid"
								},
								check: {
									type: "radio",
									radio:{
										type:"all"
									}
								},
								onSave: function(data) {
									var currentNode = $("#addApproverOfRole").data('current-node');
									$("#"+currentNode.nodeId).find("#addApprover").css("background-color",colors[color]);
									$("#"+currentNode.nodeId).find("#addApprover").css("border",0);
									$("#"+currentNode.nodeId).find("#addApprover").siblings(".personName").text(data[0].name);							
									$("#"+currentNode.nodeId).find("#addApprover").find("a").text(data[0].name.substring(0,1));
									$("#"+currentNode.nodeId).find("#addApprover").find("a").removeClass("addbtn");
									$("#"+currentNode.nodeId).find("#addApprover").find("a").addClass("name-first");
									/*$("#"+currentNode.nodeId).find("#addApprover").after('<div class="editTarget" >改</div>')*/
									approver = {"nodeId":currentNode.nodeId,"orderNum":currentNode.orderNum,"userType":currentNode.userType,"userId":data[0].id.toString(),approveStatus:1};
									approverList[currentNode.orderNum-1] = approver;
								}
							});
							$("#addApproverOfRole").listpanel("show");							
						})
					}					
				}
		};
		result[auditor.userType]();
		$(".approvers #promptDiv span").text("审批人已由管理员预置")
	}
	var printDefinedApprover = function(data){
		var addBtn = "<div class='approvers-item'>" +
						"<div id='addApprover' class='approvers-item-person type-all' style='background-color: #fff;border:1px solid #229af9' title='添加'>"
							+ "<a class='addbtn' href='javascript:void(0)'>+</a>"+
						"</div>"+                      
						"<div class='personName'>添加</div>"+
						"<div class='approvers-item-line'></div>" +
				   "</div>";
		$("#approversDiv").append(addBtn);
		$("#approversDiv").data('approvers',data);
		$("#addApproverOfAll").listpanel({
			url: BASEPATH + "/base/authoriza/user/getUserListByDeptId.htm",
			dataFilter: function(data) {
				data = data.data;
				for (var i in data) {
					if (data[i].type != 'USER') {
						data[i].noCheck = true;
						data[i].icon = "icon-group";
					}
				}
				return data;
			},
			view: {
				idKey: "id",
				nameKey: "name",
				pidKey: "pid"
			},
			check: {
				type: "radio",
				radio:{
					type:"all"
				}
//				type: "checkbox",
//				checkbox: {
//					type: {
//						"Y": "p",
//						"N": "s"
//					}
//				}
			},
			onSave: function(nodes) {
				   var tempUsersId=[];
				   var tempUsersName=[];
				   nodes.reverse();
				   $.each(nodes,function(i,val){
					   if(val.type=='USER'){
						   if($.inArray(val.id,tempUsersId) == -1){
							   tempUsersId.push(val.id);
							   tempUsersName.push(val.name);
						   } 								   
					   }
				   });			
				   if((approverList.length+tempUsersId.length)>approversMaxCount){
					   $(".error").text("审批人超出最大数量！").show().delay(2000).hide(0);
					   return;
				   }
				   var html = "";
				   $.each(tempUsersName,function(i,val){
					   var firstNameText = val.substring(0,1);
					   var col_index = i%colors.length;
					   var node_index = approverList.length;
					   html += "<div class='approvers-item'>" +
									"<div data-index="+node_index+" class='approvers-item-person person-delete' style='background-color: "+colors[col_index]+"' title='点击移除 '>" +
									"<span class='name-first'>"+firstNameText+"</span>" +
									" <div class='closeTarget'></div>"+
									"</div>" +
									"<div class='personName'>"+val+"</div>" +
									"<div class='approvers-item-type'>"+data[node_index].nodeName+"</div>" +
									"<div class='approvers-item-line'></div>" +
								"</div>";
					   approverList.push({nodeId:data[node_index].nodeId,orderNum:data[node_index].orderNum,userType:"userId",userId:tempUsersId[i].toString(),approveStatus:1});
				   });								  				
				   $("#addApprover").parent().before(html);									   
				}
		});
		$("#addApprover").unbind("click");
		$("#addApprover").bind('click',function(){
			$("#addApproverOfAll").listpanel("show")
		});
	}
	
	$("#approversDiv").on('click','.person-delete',function(){
		var index = $(this).data("index");
		var data = $("#approversDiv").data("approvers");
		approverList.splice(index,1);
		$.each(approverList,function(i,val){
			val.nodeId = data[i].nodeId;
			val.orderNum = data[i].orderNum;
		});
		$(this).parent().remove();
		$.each($('.approvers-item-type'),function(i,val){
			$(this).text(data[i].nodeName);
		})
	})

	//加载审批人
	var approverInit = function(key,branchVal){
		ajax.init().success(function(code,msg,data){
			if(code==0){
				$("#approversDiv").empty();
				if(data.hasSet){									
					if(data.approvers && data.approvers.length > 0){
						var html="";
						approversMaxCount = data.approvers.length;
						approverList = new Array(approversMaxCount);
						$.each(data.approvers,function(i,val){								
							paintApproverHtml(val,i);
					   });
					}else{
						ajax.init().success(function(code,msg,data){
							if(code == 0){
								approversMaxCount = data.length;
								approverList = [];
								$("#promptDiv").find("span").text("审批人已由管理员预置（未找到指定条件类型审批人）")
								printDefinedApprover(data);
							}
						}).post(BASEPATH+"/oa/act/approver/queryProcessAllNode.htm" ,{processKey:$("#processKey").val()})	
					}
				}else{
					ajax.init().success(function(code,msg,data){
						if(code == 0){
							approversMaxCount = data.length;
							approverList = [];
							$("#promptDiv").find("span").text("该流程添加审批人最大数量："+approversMaxCount+"人")
							printDefinedApprover(data);
						}
					}).post(BASEPATH+"/oa/act/approver/queryProcessAllNode.htm" ,{processKey:$("#processKey").val()})
				}
			}
		}).post(BASEPATH+"/oa/act/approver/queryProcessApproversInfo.htm",{"processKey":key,"des":branchVal})
	}

	function initFormData(main, html, isProcessId, num) {
		var len = main.cols.length;
		var col_idex = 0;
		var tabName = main.tab.tableKey;
		var isProcess = $("#" + isProcessId).val();
		var className = "textbox-text";
		if (num != undefined && num != null) {
			className = "tab-text";
		}
		$.each(main.cols, function(i, col) {
			var show =  !(col.showType==actcont.showType.FORM_SHOWTYPE_HIDDEN);
			if (col_idex == 0) {
				html += "<li"+(show?"":" style='display:none'")+">";
			} else {
				html += "</li><li"+(show?"":" style='display:none'")+">";
			}
			var colId = tabName + "-" + col.colName;
			if (num != undefined && num != null) {
				colId = colId + "-" + num;
			}
			var isRequire = "";
			//判断是否必填项//
			if (col.isRequire != null && col.isRequire == 0) {
				isRequire = "<span class='star'>*</span>";
			}
			if (col.isProcess != null && col.isProcess == 0) {
				isProcess = isProcess + colId + ","
			}

			var properties = "";

			if(col.properties!=undefined&&col.properties!=null&&col.properties.trim().length>0){
				properties = eval("("+col.properties+")");

			}

			var placeholder = "请输入" + col.colNameCh;

			if (undefined != properties.prompt && null != properties.prompt) {
				placeholder = properties.prompt;
			}

			var dataOptions = "{'showType':'" + col.showType + "','checkType':'" + (col.checkType != undefined ? col.checkType : "") + "','id':'" + colId + "','dataId':'" + col.dataId +"','dataSource':'"+col.dataSource+ "','colNameCh':'" + col.colNameCh + "','colName':'" + col.colName + "','isRequire':'" + (col.isRequire != undefined ? col.isRequire : "1") + "','dataOnchange':'" + (col.dataOnchange != undefined ? col.dataOnchange : "") + "'}";

			if (col.showType==actcont.showType.FORM_SHOWTYPE_HIDDEN){
				html+='<span style="height: 0px;"><input type="hidden" class="'+className+'" id="'+colId+'" name="'+colId+'" vlaue=""  options="'+dataOptions+'" /></span>';
			//多行文本处理//
			}else if (col.showType==actcont.showType.FORM_SHOWTYPE_TEXTAREA) {
				html+='<span>'+isRequire+col.colNameCh+'</span><span>'+
						'<textarea rows="3" cols="20" id="'+colId+'" name="'+colId+'" class="'+className+'"  placeholder="'+placeholder+'"  options="'+dataOptions+'" maxlength="'+col.colLength/2+'"></textarea>'+
						'</span>';
			//文本框处理//
			}else if(col.showType==actcont.showType.FORM_SHOWTYPE_TEXT){
				html+='<span>'+isRequire+col.colNameCh+'</span><span><input type="text" placeholder="'+placeholder+'"  options="'+dataOptions+'"  id="'+colId+'" name="'+colId+'" value="" class="'+className+'"   maxlength="'+col.colLength/2+'"/></span>';
			//数字处理//
			}else if(col.showType==actcont.showType.FORM_SHOWTYPE_INTEGER){

				if(undefined != properties.min && null != properties.min){
					html+='<span>'+isRequire+col.colNameCh+'</span><span><input type="number" placeholder="'+placeholder+'"  options="'+dataOptions+'"  id="'+colId+'" name="'+colId+'"  class="'+className+'"  min="'+properties.min+'" onblur="javascript:this.value=(this.value==\'\'?\'\':parseFloat(this.value < this.min?this.min:this.value).toFixed(0))"/></span>';
				}else{
					html+='<span>'+isRequire+col.colNameCh+'</span><span><input type="number" placeholder="'+placeholder+'"  options="'+dataOptions+'"  id="'+colId+'" name="'+colId+'"  class="'+className+'"  onblur="javascript:this.value=(this.value==\'\'?\'\':parseFloat(this.value).toFixed(0))"/></span>';
				}
			//浮点数字处理//
			}else if(col.showType==actcont.showType.FORM_SHOWTYPE_NUMBER){
				if(undefined != properties.min && null != properties.min){
					html+='<span>'+isRequire+col.colNameCh+'</span><span><input type="number" placeholder="'+placeholder+'"  options="'+dataOptions+'"  id="'+colId+'" name="'+colId+'"  class="'+className+'" min="'+properties.min+'" onblur="javascript:this.value=(this.value==\'\'?\'\':parseFloat(this.value < this.min?this.min:this.value).toFixed(2))"/></span>';
				}else{
					html+='<span>'+isRequire+col.colNameCh+'</span><span><input type="number" placeholder="'+placeholder+'"  options="'+dataOptions+'"  id="'+colId+'" name="'+colId+'"  class="'+className+'"  onblur="javascript:this.value=(this.value==\'\'?\'\':parseFloat(this.value).toFixed(2))"/></span>';
				}
				//下拉框处理//
			} else if (col.showType == actcont.showType.FORM_SHOWTYPE_SELECT) {
				html += '<span>' + isRequire + col.colNameCh + '</span><span>' +
					'<input  options="' + dataOptions + '" placeholder="' + placeholder + '" type="text" id="' + colId + '"  class="' + className + '" name="' + colId + '" />' +
					'</span>';
				//多选下拉框处理//
			} else if (col.showType == actcont.showType.FORM_SHOWTYPE_MSELECT) {
				html += '<span>' + isRequire + col.colNameCh + '</span><span><input placeholder="' + placeholder + '"   options="' + dataOptions + '"  type="text" id="' + colId + '" name="' + colId + '" class="' + className + '" /></span>';
				//单选树处理//
			} else if (col.showType == actcont.showType.FORM_SHOWTYPE_TREE) {
				html += '<span>' + isRequire + col.colNameCh + '</span><span><input placeholder="' + placeholder + '"  options="' + dataOptions + '"  type="text" id="' + colId + '" name="' + colId + '" class="' + className + '"/></span>';
				//多选处理//
			} else if (col.showType == actcont.showType.FORM_SHOWTYPE_MTREE) {
				html += '<span>' + isRequire + col.colNameCh + '</span><span><input placeholder="' + placeholder + '" options="' + dataOptions + '"  type="text" id="' + colId + '" name="' + colId + '" class="' + className + '" /></span>';
				//文件上传处理//
			} else if (col.showType == actcont.showType.FORM_SHOWTYPE_FILE) {
				html += '<span>' + isRequire + col.colNameCh + '</span><span ><input placeholder="' + placeholder + '" options="' + dataOptions + '"  type="file" id="' + colId + '" name="' + colId + '" class="' + className + '" /></span>';
				//日期 年月日处理//
			} else if (col.showType == actcont.showType.FORM_SHOWTYPE_DATEBOX) {
				//require.async("resource/js/component/mobileDate.js",function(jeDate){});
				html += '<span>' + isRequire + col.colNameCh + '</span><span>' +
					'<input class="' + className + ' btnDateCla mui-btn mui-btn-block"  options="' + dataOptions + '" data-options="{\'type\':\'date\',\'beginYear\':2010,\'endYear\':2116}"  placeholder="' + placeholder + '"  id="' + colId + '" name="' + colId + '" type="text" placeholder="请选择"  readonly />' +
					'</span>';
				//日期 年月日时分秒处理//
			} else if (col.showType == actcont.showType.FORM_SHOWTYPE_DATETIMEBOX) {
				//require.async("resource/js/component/mobileDate.js",function(jeDate){});
				html += '<span>' + isRequire + col.colNameCh + '</span><span>' +
					//				'<input class="'+className+' datainp"  options="'+dataOptions+'" placeholder="'+placeholder+'"  id="'+colId+'" name="'+colId+'" type="text" placeholder="请选择"  readonly  class="'+className+'" /><div type="button"  class="dateClass" onClick="jeDate({dateCell:\'#'+colId+'\',isTime:true,format:\'YYYY-MM-DD hh:mm:ss\'},this)"></div>'+
					'<input class="' + className + ' btnDateCla mui-btn mui-btn-block"  options="' + dataOptions + '" placeholder="' + placeholder + '" data-options="{\'beginYear\':2010,\'endYear\':2116}"  id="' + colId + '" name="' + colId + '" type="text" placeholder="请选择"  readonly />' +
					'</span>';
			}else if(col.showType == actcont.showType.FORM_SHOWTYPE_BOOKS){
				html+='<span>'+isRequire+col.colNameCh+'</span><span>'
				+'<input type="text" readonly placeholder="'+placeholder+'"  options="'+dataOptions+'"  id="books-'+colId+'" name="books-'+colId+'" value="" class="'+className+'"   maxlength="'+col.colLength/2+'"/>'
				+'<i class="input-clear"></i>'
				+'<input type="hidden" id="'+colId+'" name="'+colId+'" value="">'
				+'</span>';
			}
			col_idex++;
		});
		$("#" + isProcessId).val(isProcess);
		return html + "</tr>";
	}

	function initTableData(subs, num) {
		//封装表格列 数据
		var columnsList = [];
		var tabHtml = "";
		//		var isProcess= $("#subIsProcess").val();
		if (subs.cols && subs.cols.length > 0) {
			var tabName = subs.tab.tableKey;
			// var width=0;
			//			 var colsStr = JSON.stringify(subs.cols);
			tabHtml = "<ul sign='processTable' class='form_m inputStyle' name='" + tabName + "' id='" + tabName + "-" + num + "'>" +
				"<caption><div class='sub-title' style='border-radius:0;'>" + subs.tab.shortNameCh + "明细(<span>" + (num + 1) + "</span>)<input type='button' value='删除' style='float:right;display:" + (num == 0 ? "none" : "") + "' class='sub-deleteBtn' /></div>" +
				"</caption>";
			tabHtml = initFormData(subs, tabHtml, "subIsProcess", num);
		}
		if (tabHtml != "") {
			tabHtml += "</ul>";
		}
		return tabHtml;
	}

	function addRowNum(tabId) {
		var trs = $("#" + tabId).find("tr");
		$.each(trs, function(i, tr) {
			if (i != 0) {
				var td = tr.childNodes[0];
				td.innerHTML = i;
			}

		});
	}

	function resetRowTab(tabId) {
		var captions = $("#" + tabId).find("caption");
		$.each(captions, function(i, caption) {
			var font = caption.childNodes[0].childNodes[1];
			font.innerHTML = (i + 1);

		});
	}

	function addTab(id, cols) {
		//判断tab是否存在
		if (typeof($("#" + id)) != 'undefined') {
			var tab = $("#" + id); //获得表格
			var num = $("#" + id + " tr").length; //表格当前的行数
			var index = 0;
			var trId = id + "_tr_" + num;
			var tabInput = "<tr id='" + trId + "'>";
			//		    //插入序号列
			//		    tabInput+="<td>"+num+"</td>";
			index++;
			//插入数据列
			$.each(cols, function(i, col) {
				var colId = id + "-" + col.colName + "-" + num;
				var dataOptions = "{'showType':'" + col.showType + "','checkType':'" + (col.checkType != undefined ? col.checkType : "") + "','id':'" + colId + "','dataId':'" + col.dataId + "','colNameCh':'" + col.colNameCh + "','isRequire':'" + (col.isRequire != undefined ? col.isRequire : "1") + "','dataOnchange':'" + (col.dataOnchange != undefined ? col.dataOnchange : "") + "'}";
				//隐藏域处理//
				if (col.showType == actcont.showType.FORM_SHOWTYPE_HIDDEN) {
					tabInput += '<td>&nbsp;</td>';
					//多行文本处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_TEXTAREA) {
					tabInput += '<td><textarea rows="3" cols="20" id="' + colId + '" name="' + colId + '" options="' + dataOptions + '"  class="tab-text"></textarea></td>';
					//文本框处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_TEXT) {
					tabInput += '<td><input type="text" id="' + colId + '" name="' + colId + '" value="" options="' + dataOptions + '"   class="tab-text"/></td>';
					//数字处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_INTEGER) {
					tabInput += '<td><input type="number" id="' + colId + '" name="' + colId + '" options="' + dataOptions + '"   class="tab-text" onblur="javascript:this.value=(this.value==\'\'?\'\':parseFloat(this.value).toFixed(0))"/></td>';
					//浮点数字处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_NUMBER) {
					tabInput += '<td><input type="number" id="' + colId + '" name="' + colId + '"  options="' + dataOptions + '"  class="tab-text" onblur="javascript:this.value=(this.value==\'\'?\'\':parseFloat(this.value).toFixed(2))"/></td>';
					//下拉框处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_SELECT) {
					tabInput += '<td><input type="text" id="' + colId + '" name="' + colId + '" options="' + dataOptions + '"  class="tab-text" /></td>';
					//多选下拉框处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_MSELECT) {
					tabInput += '<td><input type="text" id="' + colId + '" name="' + colId + '" options="' + dataOptions + '"  class="tab-text"/></td>';
					//单选树处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_TREE) {
					html += '<td ><input type="text" id="' + colId + '" name="' + colId + '" options="' + dataOptions + '"   class="tab-text" /></td>';
					//多选处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_MTREE) {
					html += '<td ><input type="text" id="' + colId + '" name="' + colId + '" options="' + dataOptions + '"  class="tab-text" /></td>';
					//文件上传处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_FILE) {
					html += '<td ><input type="text" id="' + colId + '" name="' + colId + '" options="' + dataOptions + '"   class="tab-text"/></td>';
					//日期 年月日处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_DATEBOX) {
					//require.async("resource/js/component/mobileDate.js",function(jeDate){});
					tabInput += '<td><input class="tab-text btn mui-btn mui-btn-block"  options="' + dataOptions + '" data-options="{\"type\":\"date\"}"  placeholder="请输入' + col.colNameCh + '"  id="' + colId + '" name="' + colId + '" type="text" placeholder="请选择"  readonly /></td>';
					//日期 年月日时分秒处理//
				} else if (col.showType == actcont.showType.FORM_SHOWTYPE_DATETIMEBOX) {
					//require.async("resource/js/component/mobileDate.js",function(jeDate){});
					tabInput += '<td><input class="tab-text btn mui-btn mui-btn-block"  options="' + dataOptions + '" data-options="{\"type\":\"date\"}"  placeholder="请输入' + col.colNameCh + '"  id="' + colId + '" name="' + colId + '" type="text" placeholder="请选择"  readonly /></td>';
				}
				index++;
			});
			//插如删除列
			tabInput += "<td><input type='button' class='acitiviti_btn' /></td>";
			tab.append(tabInput);
			addInputEvent($("#" + trId).find(".tab-text"));
		}
	}

	function addFormEvent() {
		$("input:button[id*='addTableBtn_']").bind("click", function(e) {
			var tab = $("#subsTab");
			var html = tab.html();
			var tabId = e.target.id;
			var num = $(".sub-deleteBtn").size();
			//			var cols = document.getElementById(tabId).cols;
			var subs = document.getElementById(tabId).subs;
			var tableKey = document.getElementById(tabId).getAttribute('tabKey');
			//			addTab(tableKey,JSON.parse(cols));
			$("#subsTab").append(initTableData(JSON.parse(subs), $(".sub-deleteBtn").size()));
			getDATE(mui);
			//			tab.html(html);
			addInputEvent($("#" + tableKey + "-" + num).find(".tab-text"));
			$(".sub-deleteBtn").unbind("click");
			$(".sub-deleteBtn").bind("click", function(e) {
				$(this).parent().parent().remove();
				resetRowTab("subsTab");
			});

		});
		//		$.parser.onComplete=null;
		addInputEvent($("#processForm").find(".textbox-text"));
		addInputEvent($("#subsForm").find(".textbox-text"));
		addInputEvent($("#subsForm").find(".tab-text"));
		//		loadSubs_view();
		//		loadSubs();
//		$("#btns").find("input").bind("click", function(e) {
//			submit.checkForm(this, e.target.value, $(e.target).attr('documentation'));
//		});
		loadBtns();
	}

	function addInputEvent(ins) {
		$.each(ins, function(i, input) {
			var opt = eval('(' + $(input).attr('options') + ')');
			var showType = opt.showType;
			if (showType == actcont.showType.FORM_SHOWTYPE_SELECT && opt.dataId && opt.dataId != '') {
				var dataId = opt.dataId;
				if (dataId.indexOf("UC") == 0) { //用户自定义流程下拉框
					comboxLoad(opt.id, "actcode", false, dataId);
				}else if(dataId == "link"){
					if(opt.dataSource){
						comboxLoad(opt.id, null,false,null,opt.dataSource);
					}
				}else if(dataId == "basecode"){
					//加载下拉框数据   
					var dataSource = opt.dataSource;
					if(dataSource && dataSource != ''){
						var source = dataSource.split(',');
						comboxLoad(opt.id, dataId,false, getComboxParam(source));
					}else{
						comboxLoad(opt.id, dataId,false, '');
					}
				}
				
				//绑定联动字段
				var dataOnchange = opt.dataOnchange;
				if(dataOnchange && $('#'+dataOnchange).length > 0){
					var $obj = $('#'+opt.id);
					var $target = $('#'+dataOnchange);
					var options = eval('('+$target.data('options')+')');
					if(options.showType == actcont.showType.FORM_SHOWTYPE_SELECT){
						$obj.combobox({
							onChange:function(newVal,oldVal){
								comboxLoad(dataOnchange, options.dataId,false, newVal);
							}
						});
					}else if(options.showType == actcont.showType.FORM_SHOWTYPE_HIDDEN){
						$obj.combobox({
							onChange:function(newVal,oldVal){
								$target.val(newVal);
							}
						});
					}
				}
			} else if (showType == actcont.showType.FORM_SHOWTYPE_MSELECT && opt.dataId && opt.dataId != '') {
				require("resource/js/mobile/awesome/css/font-awesome.css");
				require("resource/js/mobile/css/textbox.css");
				require("resource/js/mobile/css/combobox.css");
				require("resource/js/mobile/jquery.textbox.js");
				require("resource/js/mobile/jquery.combobox.js");
				comboxLoad(opt.id, "actcode", true, opt.dataId);
			} else if (showType == actcont.showType.FORM_SHOWTYPE_TREE && opt.dataId && opt.dataId != '') {
				treeLoad(input.id, opt.dataId, opt.dataOnchange, "radio");
			} else if (showType == actcont.showType.FORM_SHOWTYPE_MTREE && opt.dataId && opt.dataId != '') {
				treeLoad(input.id, opt.dataId, opt.dataOnchange, "checkbox");
			} else if (showType == actcont.showType.FORM_SHOWTYPE_FILE) {
				if (appCheck()) {
					//上传文件
					require.async(["resource/js/mobile/awesome/css/font-awesome.css", "resource/js/mobile/css/textbox.css", "resource/js/mobile/css/upload.css",
						"resource/js/mobile/jquery.upload.js", "resource/js/mobile/jquery.textbox.js"
					], function(upload) {
						$(input).upload({
							type:"file"
						});
					});
				} else {
					//上传文件
					require.async(["resource/js/mobile/awesome/css/font-awesome.css", "resource/js/mobile/css/textbox.css", "resource/js/mobile/css/upload.css",
						"resource/js/mobile/jquery.uploadios.js", "resource/js/mobile/jquery.textbox.js"
					], function(upload) {
						$(input).upload({
							buttonText: "",
							exts: ['png', 'gif', 'jpg', 'mp4', 'txt', 'doc', 'docx', 'xsl', ''],
						});
					});
				}
			}else if(showType== actcont.showType.FORM_SHOWTYPE_BOOKS){
				var books = $(input).vitoBooks({
					checkType:'radio',
					userType:opt.dataSource,
					closed: true,
					onSave:function(nodes){
						var text = '';
						var value = '';
						$.each(nodes,function(i,item){
							text += item.name +',';
							value += item.id + ',';
						});
						if($('#'+opt.id).val().indexOf(value.substring(0,text.length-1))>-1 && $(input).val().indexOf(text.substring(0,text.length-1))>-1){
							$(".error").text("不能重复选择").show().delay(2000).hide(0);
							return
						}
						if(opt.dataId == 'checkbox'){
							text = text + $(input).val();
							value = value + $('#'+opt.id).val();
						}
						text = text.substring(0,text.length-1);
						value = value.substring(0,value.length-1);
						$(input).val(text);
						$('#'+opt.id).val(value);
						text.length>0 && $(input).siblings('.input-clear').css('display','inline');
					}
				});
				$(input).unbind('click');
				$(input).bind('click',function(){
					books.vitoBooks('open');
				});
				$(input).siblings('.input-clear').unbind('click');
				$(input).siblings('.input-clear').bind('click',function(){
					$(input).val("");
					$('#'+opt.id).val("");
					$(this).hide();
				});
			}
		});
	}

	function comboxLoad(id, dataId, isMutil, param,url) {
		$("#" + id).combobox({
			url:url || BASEPATH + "/base/authoriza/conmonData/queryDataNoCache.htm?queryId=" + dataId + "&param=" + param,
			dataFilter: function(data) {
				if (data.data != undefined) {
					return data.data;
				} else {
					return "";
				}
			},
			textFiled: "text",
			valueFiled: "id",
			isMutil: isMutil
		});
	}

	function treeLoad(id, dataId, param, type) {
		require.async(["resource/js/mobile/awesome/css/font-awesome.css", "resource/js/mobile/css/textbox.css", "resource/js/mobile/css/combobox.css", "resource/js/mobile/css/listview.css",
			"resource/js/mobile/jquery.listview.js", "resource/js/mobile/jquery.textbox.js", "resource/js/mobile/jquery.listbox.js"
		], function(listview, textbox, listbox) {
			$("#" + id).listbox({
				url: BASEPATH + "/base/authoriza/conmonData/queryDataNoCache.htm?queryId=" + dataId + "&param=" + param,
				dataFilter: function(data) {
					return data.data;
				},
				view: {
					idKey: "id",
					nameKey: "name",
					pidKey: "pid"
				},
				check: {
					type: type,
					radio: {
						type: "all"
					}
				}
			});
		});
	}
	//解决安卓部分版本无法打开图片bug，使用原生，判断是否是安卓
	function appCheck() {
		var u = navigator.userAgent,
			app = navigator.appVersion;
		var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
		//var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
		return isAndroid;
	}

	function getComboxParam(dataOnchanges) {
		var param = "";
		$.each(dataOnchanges, function(i, dataOnchange) {
			if ($("#" + dataOnchange).length > 0) {
				param += $("input[name='" + dataOnchange + "']").val();
			} else {
				param += dataOnchange;
			}
			if (i > 0) {
				param += ",";
			}
		});
		return param;
	}

/*	function setUrlParam() {
		//获取默认小区id和名称
		var btns = $("#btns").find("input")
		$.each(btns, function(i, input) {
			if ($(input).attr('documentation') != undefined) {
				var processDatas = $(input).attr('documentation');
				var processData = {};
				if (processDatas != "" && processDatas.length > 0) {
					processData = eval('(' + processDatas + ')');
					//流程设置js校验
					if (processData != null) {
						if (processData.hasOwnProperty("loadJs")) {
							var loadJs = processData.loadJs;
							if (loadJs != null && loadJs != "") {
								loadJs = loadJs.replace(/\^/g, "\"");
								var temp = eval("(" + loadJs + ")");
								temp(ajax, BASEPATH, null, '1');
							}
						}
						//						if(processData.hasOwnProperty("loadJsName")){
						//							if(processData.loadJsName=="setOverTime"){
						//								setOverTime();
						//							}
						//						}
					}
				}
			}
		});
	}*/

	function setOverTime(id, val) {
		if (id == "overtime-start_time" || id == "overtime-end_time") {
			//以下写onchange的逻辑
			var startTime = "";
			var endTime = "";
			if (id == "overtime-start_time") {
				startTime = val.replace(/-/g, '/');
				endTime = $("#overtime-end_time").val().replace(/-/g, '/');
			} else if (id == "overtime-end_time") {
				startTime = $("#overtime-start_time").val().replace(/-/g, '/');
				endTime = val.replace(/-/g, '/');
			}
			if (startTime != null && startTime != "" && endTime != null && endTime != "") {
				var sDate = new Date(startTime);
				var eDate = new Date(endTime);
				if (sDate >= eDate) {
					 $("#overtime-start_time").val('');
					$("#overtime-end_time").val('');
					$(".error").text("开始时间不能大于结束时间！").show().delay(2000).hide(0);
					//return; 
				} else {
					var dateHour = eDate.getTime() - sDate.getTime();
					var num = dateHour / (3600 * 1000); //计算开始时间结束时间相差几个小时，精确到小数点后1位
					$("#overtime-overtime_time").val(num.toFixed(1));
				}
			}
		}
	}

	function showMask() {
		$('.Mask').show();
		$('#maskText').show();
	}

	function hideMask() {
		$('.Mask').hide();
		$('#maskText').hide();
	}

	function disableBtn(){
		$('#btns').children().addClass('l-btn-disabled');
	}
	function enableBtn(){
		$('#btns').children().removeClass('l-btn-disabled');
	}
	function loadBtns() {
		$("#cancel").click(function() {
			$(".Mask").hide();
			$(".alertDelete").hide();
		});
		var urlTool = require("resource/js/component/urlTool.js");
		var processInstanceId = urlTool.getParam("processInstanceId");
		var bussId = $("#busenessId").val();
		//setUrlParam();
		//当前登录用户ID
		var currentUser = $("#currentUserId").val();
		var taskId = urlTool.getParam("taskId");
		var key = urlTool.getParam("key");
		var processNodeId = $("#processNodeId").val();
		var businessId = $("#busenessId").val();
		
		//绑定打印按钮事件
		  if(typeof($("#printBtn")) != 'undefined' && $("#printBtn").length > 0){
			  $("#printBtn").unbind("click");
			  $("#printBtn").bind("click", function() {
	              $(".Mask").show();
			      ajax.init().success(function(code,msg,data){
			          if(code==0){
			              var param=data.filePath+data.fileId+"."+data.fileExt;   
			              $("#alertMessage").text(msg);
			              $(".alertDelete").show();
			              $("#apply").off("click");
			              $("#apply").on("click",function(){                                                  
			                  window.location.href=BASEPATH+"/download/file/"+param;
			                  $(".alertDelete").hide();
			                  $(".Mask").hide();
			                  $(".error").text("下载成功！").show().delay(1000).hide(0);
			              });         
			                $(".Mask,#cancel").click(function(){
			                    $(".alertDelete").hide();
			                });
			          }
			      }).error(function(code, msg, data) {
			          setTimeout(function() {
			              $(this).attr("disabled", false)
			          }, 1000);
			          $(".error").text("打印失败！").show().delay(1000).hide(0);
			      }).post(BASEPATH+"/oa/act/print/printprocess.htm",{"businessId":businessId})
			  })
		  }
		  
		//绑定终止按钮事件
		if (typeof($("#endProcess")) != 'undefined' && $("#endProcess").length > 0) {
			$("#endProcess").unbind("click");
			$("#endProcess").bind("click", function() {
				var btnName = $(this).find('span').text();
				submit.checkForm(this, btnName, "",null, function(data) {
					require.async('resource/js/component/ajax.js', function(ajax) {
						ajax.init().success(function(code, msg, datas) {
								if (code == 0) {
									//处理任务后关闭页签并刷新待办任务页签
									$(".error").text(btnName+"成功").show().delay(1000).hide(0);
									setTimeout(function() {
										submit.goBack();
										}, 1000);
								} else {
									$(".error").text(msg).show().delay(1000).hide(0);
								}

							}).error(function(code, msg, datas) {
								enableBtn()
								$(".error").text("拒绝失败！").show().delay(1000).hide(0);
							}).contentType('application/json')
							.post(BASEPATH + '/oa/act/activitiMain/endProcess.htm', JSON.stringify(data));
					});
				});

			});
		}
		
		//绑定提交事件
		if (typeof($(".assignRoleProcess")) != 'undefined' && $(".assignRoleProcess").length > 0) {		
			$(".assignRoleProcess").unbind("click");
			$(".assignRoleProcess").bind("click", function(){
				var btnName = $(this).val()||$(this).find('span').text();
				if($(this).data('options')){
					param = JSON.stringify($(this).data('options'));
				}
				submit.checkForm(this, btnName, param,approverList);								
			})

		}
		//转发事件
		if(typeof($('#transfer')) != 'undefined' &&$('#transfer').length > 0 ){
			$("#addTranfer").listpanel({
				url: BASEPATH + "/base/authoriza/user/getUserListByDeptId.htm",
				dataFilter: function(data) {
					data = data.data;
					for (var i in data) {
						if (data[i].type != 'USER') {
							data[i].noCheck = true;
							data[i].icon = "icon-group";
						}
					}
					return data;
				},
				view: {
					idKey: "id",
					nameKey: "name",
					pidKey: "pid"
				},
				check: {
					type: "radio",
				},
				onSave: function(nodes) {
					disableBtn();
					var checked = nodes[0].id.toString(); 
					if($('#currentUserId').val().toString().trim() == checked.trim()){
						enableBtn();
						$(".error").text('不能转交给自己').show().delay(1000).hide(0);
						return;
					}
					ajax.init().success(function(code,msg,data){
						if(code=='0'){						
							$(".error").text(msg).show().delay(1000).hide(0);
							setTimeout(function() {
								submit.goBack();
							}, 1000);							
						}else{
							enableBtn();
							$(".error").text(msg).show().delay(1000).hide(0);
						}
					}).post(BASEPATH+"/oa/act/activitiMain/transfer.htm",{taskId:$("#taskId").val(),userId:nodes[0].id.toString()});
					}
			});
			$("#transfer").unbind("click");
			$("#transfer").bind('click',function(){
				if($(this).hasClass("l-btn-disabled")){
					return;
				}
				$("#addTranfer").listpanel("show")
			});	
		}
		//挂起事件
		if (typeof($("#hangUp")) != 'undefined' && $("#hangUp").length > 0) {
			$("#hangUp").unbind("click");
			$("#hangUp").bind("click", function() {
				if($(this).hasClass("l-btn-disabled")){
					return;
				}
				disableBtn();
				ajax.init().success(function(code, msg, datas) {
					if (code == 0) {
						$(".error").text("挂起成功！").show().delay(1000).hide(0);
						setTimeout(function() {							
							window.location.reload();
						}, 1000);
					} else {
						enableBtn();
						$(".error").text(msg).show().delay(1000).hide(0);
					}
				}).error(function(code, msg, datas) {
					enableBtn();
					$(".error").text("挂起失败！").show().delay(1000).hide(0);
				}).post(BASEPATH + '/oa/act/activitiMain/hangUp.htm', {
					processInstanceId: processInstanceId,
					businessId: bussId,
					isHangUp: true
				});
			});
			//解挂事件
		} else if (typeof($("#unHangUp")) != 'undefined' && $("#unHangUp").length > 0) {
			$('#btns').find('.approval-button').hide();
			$("#unHangUp").show();
			$("#unHangUp").bind("click", function() {
				if($(this).hasClass("l-btn-disabled")){
					return;
				}
				disableBtn();
				var hangUpUser = $("#hangUpUser").val();
				if (hangUpUser == currentUser) {
					require.async('resource/js/component/ajax.js', function(ajax) {
						ajax.init().success(function(code, msg, datas) {
								if (code == 0) {
									$(".error").text("解挂成功！").show().delay(2000).hide(0);
									setTimeout(function() {
										window.location.reload();
									}, 1000);
								} else {
									enableBtn();
									$(".error").text(msg).show().delay(1000).hide(0);
								}
							}).error(function(code, msg, datas) {
								enableBtn();
								if (code == 12) {
									$(".error").text("您不是挂起人，无权解挂该任务！").show().delay(1000).hide(0);
								} else{
									$(".error").text("解挂失败！").show().delay(1000).hide(0);
								}
							})
							.post(BASEPATH + '/oa/act/activitiMain/hangUp.htm', {
								processInstanceId: processInstanceId,
								businessId: bussId,
								isHangUp: false
							});
					});
				} else {
					enableBtn();
					$(".error").text("您不是挂起人，无权解挂该任务！").show().delay(2000).hide(0);
				}

			});
		} else {}
		
		//更多按钮
		if(typeof($('moreBtns')) != 'undefined' && $("#moreBtns").length > 0){
			disableBtn();
			$('#moreBtns').unbind('click');
			$('#moreBtns').bind('click',function(){
				showMask();
				$('#btnsDlg').show();
			});
		}

	}
});
